home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / PPaint / ColorType / Rexx / ViewFile.ctrx < prev    next >
Text File  |  1996-05-02  |  1KB  |  59 lines

  1. /* ColorType Amiga Rexx script - Copyright © 1996 Cloanto Italia srl */
  2.  
  3. /* $VER: ViewFile.ctrx 1.0 */
  4.  
  5. /**
  6.  This script shows how to create a simple text viewer. It displays the
  7.  selected text file in a window.
  8. */
  9.  
  10. IF ARG(1, EXISTS) THEN
  11.     PARSE ARG CTPORT
  12. ELSE
  13.     CTPORT = 'COLORTYPE'
  14.  
  15. IF ~SHOW('P', CTPORT) THEN DO
  16.     IF EXISTS('ColorType:ColorType') THEN DO
  17.         ADDRESS COMMAND 'Run >NIL: ColorType:ColorType'
  18.         DO 30 WHILE ~SHOW('P',CTPORT)
  19.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  20.         END
  21.     END
  22.     ELSE DO
  23.         SAY "ColorType could not be loaded."
  24.         EXIT 10
  25.     END
  26. END
  27.  
  28. IF ~SHOW('P', CTPORT) THEN DO
  29.     SAY 'ColorType Rexx port could not be opened.'
  30.     EXIT 10
  31. END
  32.  
  33. ADDRESS VALUE CTPORT
  34. OPTIONS RESULTS
  35. OPTIONS FAILAT 10000
  36.  
  37. LockGUI
  38. RequestFile '"Select a text file"'
  39. IF RC = 0 THEN DO
  40.     PARSE VALUE RESULT WITH '"' fname '"'
  41.     IF OPEN('textfile', fname, R) THEN DO
  42.         filetext = ''
  43.         DO UNTIL EOF('textfile')
  44.             filetext = filetext || READCH('textfile', 10000)
  45.         END
  46.         CALL CLOSE('textfile')
  47.         pos = 1
  48.         DO FOREVER
  49.             pos = INDEX(filetext, '"', pos)
  50.             IF pos = 0 THEN
  51.                 BREAK
  52.             filetext = INSERT('"', filetext, pos)
  53.             pos = pos + 2
  54.         END
  55.         RequestNotify '"File contents" "'filetext'" SCROLL WRAPCHECK'
  56.     END
  57. END
  58. UnlockGUI
  59.